<template>
	<view style="padding: 5px">
		<uni-row>
			<uni-col>
				<uni-datetime-picker v-model="rq" type="date" :clear-icon="false" :end="Date.now()" @change="getMorningExercisesStuByClassId"/>
			</uni-col>
		</uni-row>
		
		<uni-card v-for="(item,index) in resList" :key="index" :title="item.className">
			<view>
				<text>姓名：{{item.studentName}}</text>
				<text style="float: right;color: red;">类型：{{getType(item.type)}}</text>
			</view>
		</uni-card>
	</view>
</template>

<script>
	import morningExercises from '@/api/modules/morningExercises.js'

	export default {
		onLoad(options) {
			this.rq = options.rq;
			this.classId = options.classId;
			this.getMorningExercisesStuByClassId();
		},
		data() {
			return {
				resList:[],
				rq: '',
				classId : '',
			}
		},
		methods: {
			getMorningExercisesStuByClassId() {
				morningExercises.getMorningExercisesStuByClassId(this.classId,this.rq).then( res => {
					console.log("早操学生信息：",res.data);
					this.resList = res.data;
				})
			},
			getType(type) {
				if(type === 1) {
					return '请假'
				}else if(type === 2) {
					return '临时请假'
				} else {
					return '未到'
				}
			}
		}
	}
</script>


<style>
</style>
